package com.wushi.smartorm;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ResourceBundle;

/**
 * @program: smartorm
 * @description:
 * @author: Grant Wu
 * @create: 2020-05-31 15:50
 **/

public class JDBCUtils {
    private static ResourceBundle jdbcBundle;
    static {
        jdbcBundle= ResourceBundle.getBundle("smartorm-config");
        try {
            Class.forName(jdbcBundle.getString("smartorm.driver"));
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
    public static Connection getConnection() throws SQLException {

        String url = jdbcBundle.getString("smartorm.url");
        String username = jdbcBundle.getString("smartorm.user");
        String password = jdbcBundle.getString("smartorm.password");
        Connection connection = DriverManager.getConnection(url, username, password);
        return connection;
    }
}
